<template>
  <div>
    <el-table
      v-loading="loading"
      ref="currencyTable"
      :data="tableData"
      stripe
      style="width: 100%"
      @selection-change="getSelectVal"
    >
      <el-table-column type="selection" width="55" align="center">
      </el-table-column>
      <el-table-column
        type="index"
        align="center"
        label="序号"
      ></el-table-column>
      <el-table-column prop="deptName" label="部门名称">
        <template slot-scope="scope">{{ scope.row.deptName || "--" }}</template>
      </el-table-column>
      <el-table-column prop="userName" label="用户名称" width="120"
        ><template slot-scope="scope">{{
          scope.row.userName || "--"
        }}</template></el-table-column
      >
      <el-table-column prop="staffStatus" label="员工状态">
        <template slot-scope="scope">
          <span v-if="scope.row.staffStatus === 1">实习</span>
          <span v-if="scope.row.staffStatus === 2">试用期</span>
          <span v-if="scope.row.staffStatus === 3">已转正</span>
          <span v-if="scope.row.staffStatus === 4">试用不合格</span>
          <span v-if="scope.row.staffStatus === 5">已辞退</span>
          <span v-if="scope.row.staffStatus === 6">自愿离职</span>
          <span v-if="scope.row.staffStatus === 7">黑名单</span>
          <span v-else>--</span>
        </template>
      </el-table-column>
      <el-table-column prop="leader" label="负责人"
        ><template slot-scope="scope">{{
          scope.row.leader || "--"
        }}</template></el-table-column
      >
      <el-table-column prop="sex" label="性别">
        <template slot-scope="scope">
          <span v-if="scope.row.sex === 1">男</span>
          <span v-if="scope.row.sex === 2">女</span>
          <span v-else>--</span>
        </template>
      </el-table-column>
      <el-table-column prop="status" label="帐号状态">
        <template slot-scope="scope">
          <el-tag v-if="scope.row.status === '0'" type="success">正常</el-tag>
          <el-tag v-if="scope.row.status === '1'" type="danger">停用</el-tag>
        </template>
      </el-table-column>
      <el-table-column prop="phonenumber" label="联系电话" width="120">
        <template slot-scope="scope">{{
          scope.row.phonenumber || "--"
        }}</template>
      </el-table-column>
      <el-table-column prop="idCard" label="身份证号码" width="160"
        ><template slot-scope="scope">{{
          scope.row.idCard || "--"
        }}</template></el-table-column
      >
      <el-table-column prop="address" label="联系地址" width="240"
        ><template slot-scope="scope">{{
          scope.row.address || "--"
        }}</template></el-table-column
      >
      <el-table-column prop="email" label="邮箱" width="180"
        ><template slot-scope="scope">{{
          scope.row.email || "--"
        }}</template></el-table-column
      >
    </el-table>
    <el-pagination
      class="pagination mt10"
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="currentPage"
      :page-sizes="[10, 20, 30, 40]"
      :page-size="pageSize"
      layout="total, sizes, prev, pager, next, jumper"
      :total="total"
      background
    >
    </el-pagination>
  </div>
</template>

<script>
import { listUser } from "@/api/system/user";
export default {
  data() {
    return {
      tableData: [],
      currentPage: 1, //当前页
      pageSize: 10, //每页条数
      total: 0,
      loading: false,
    };
  },
  methods: {
    //分页器size
    handleSizeChange(val) {
      this.pageSize = val;
      this.getDataList();
    },
    //分页器当前页
    handleCurrentChange(val) {
      this.currentPage = val;
      this.getDataList();
    },
    getSelectVal(val) {
      // if (val.length) {
      this.$emit("getSelectVal", val);
      // }
    },
    getDataList() {
      this.loading = true;
      listUser({
        page: this.currentPage,
        pageSize: this.pageSize,
      }).then((res) => {
        this.tableData = res.rows;
        this.total = res.total;
        this.loading = false;
      });
    },
  },
  mounted() {
    this.getDataList();
  },
};
</script>

<style></style>
